package com.niit.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import com.niit.listener.LoginListener;
import com.niit.utils.Constants;

/**
 * 登陆界面
 * @author lijingwei
 *
 */
public class LoginView extends JFrame{
	 private JTextField userNameTextField;
	 private JPasswordField pwdTextField;
	 JPanel northPanel,centerPanel,southPanel;
	 JLabel titleLabel;
	
	 public LoginView() {
		 initView();
		 showView();
	 }
	 
	 
	 private void showView() {
		 titleLabel = new JLabel("图书管理系统");
		 titleLabel.setFont(new Font(Constants.FONT_STYLE, Font.BOLD, 26));
		 northPanel.add(titleLabel);
		 northPanel.setBounds(100, 20, 200, 50);
		 this.add(northPanel);
		 
		 JLabel userNameLabel = new JLabel("用户名");
		 JLabel pwdLabel = new JLabel("密码");
		 userNameTextField = new JTextField();
		 pwdTextField = new JPasswordField();
		 userNameLabel.setBounds(0, 0, 50, 30);
		 centerPanel.add(userNameLabel);
		 userNameTextField.setBounds(60, 0, 160, 30);
		 centerPanel.add(userNameTextField);
		 pwdLabel.setBounds(0, 40, 50, 30);
		 centerPanel.add(pwdLabel);
		 pwdTextField.setBounds(60, 40, 160, 30);
		 centerPanel.add(pwdTextField);
		 centerPanel.setBounds(80, 90, 300, 70);
		 this.add(centerPanel);
		 
		 JButton submitBtn = new JButton("提交");
		 submitBtn.setFont(new Font(Constants.FONT_STYLE, Font.ROMAN_BASELINE, 16));
		 submitBtn.setBounds(70, 0, 80, 35);
		 submitBtn.addMouseListener(new LoginListener(this));
		 southPanel.add(submitBtn);
		 southPanel.setBounds(90, 180, 200, 100);
		 this.add(southPanel, BorderLayout.SOUTH);
		 this.setVisible(true);
	 }
	 
	
	
	 /**
	  * 初始化界面
	  */
	 private void initView() {
		 northPanel = new JPanel();
		 centerPanel = new JPanel(null);
		 southPanel = new JPanel(null);
		 
		 this.setTitle("登陆");
		 this.setSize(400,260);
		 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 this.setLocationRelativeTo(null);
		 this.setLayout(null);
	 }


	public JTextField getUserNameTextField() {
		return userNameTextField;
	}


	public JPasswordField getPwdTextField() {
		return pwdTextField;
	}
	 
	 
	 
}
